/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gui.Produccion;

import Controlador.Bean.Ventas.PlanVentas;
import java.util.ArrayList;
import java.util.Vector;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JOptionPane;

/**
 *
 * @author j.d
 */
public class SeleccionarPlanDeVentas extends javax.swing.JInternalFrame {

    /**
     * Creates new form SeleccionarPlanDeVentas
     */

    private ArrayList<PlanVentas> PlanDeVentas;
    SeleccionarPlanDeVentas(ArrayList<PlanVentas> PlanDeVentas) {
         initComponents();
         this.PlanDeVentas = PlanDeVentas;
         Vector vector = new Vector();
         vector.add("Enero");
         vector.add("Febrero");
         vector.add("Marzo");
         vector.add("Abril");
         vector.add("Mayo");
         vector.add("Junio");
         vector.add("Julio");
         vector.add("Agosto");
         vector.add("Septiembre");
         vector.add("Octubre");
         vector.add("Noviembre");
         vector.add("Diciembre");
         txtSimples.setEditable(false);
         txtDecoradas.setEditable(false);
         txtRellenas.setEditable(false);
         txtFecha.setEditable(false);
         DefaultComboBoxModel comboModelo = new DefaultComboBoxModel(vector);
         cmbFechasPlan.setModel(comboModelo);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        cmbFechasPlan = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();
        txtFecha = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        txtSimples = new javax.swing.JTextField();
        txtDecoradas = new javax.swing.JTextField();
        txtRellenas = new javax.swing.JTextField();

        setClosable(true);

        jLabel1.setText("Seleccionar Plan:");

        cmbFechasPlan.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmbFechasPlan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cmbFechasPlanActionPerformed(evt);
            }
        });

        jLabel2.setText("Fecha:");

        jLabel3.setText("Galletas Simples:");

        jLabel4.setText("Galletas Decoradas:");

        jLabel5.setText("Galletas Rellenas:");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2)
                    .addComponent(jLabel3)
                    .addComponent(jLabel4)
                    .addComponent(jLabel5))
                .addGap(54, 54, 54)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(cmbFechasPlan, 0, 81, Short.MAX_VALUE)
                    .addComponent(txtFecha)
                    .addComponent(txtSimples)
                    .addComponent(txtDecoradas)
                    .addComponent(txtRellenas))
                .addContainerGap(153, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(cmbFechasPlan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(txtFecha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(txtSimples, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(txtDecoradas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(txtRellenas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(91, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void cmbFechasPlanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cmbFechasPlanActionPerformed
        // TODO add your handling code here:
        int mes = cmbFechasPlan.getSelectedIndex();
        boolean existe = false;
        int indice =0;
        String idPlanDeVentas;
        for(indice = 0; indice<PlanDeVentas.size(); indice++){
            
            if(PlanDeVentas.get(indice).getFechaInicio().getMonth() == mes){
                existe = true;
                break;
            }
        }
        if(existe){
            
            idPlanDeVentas = PlanDeVentas.get(indice).getIdPlanVentas();
            
            
        }else{
            JOptionPane.showMessageDialog(this,"No existe un plan de ventas para el mes seleccionado");
        }
        
        
    }//GEN-LAST:event_cmbFechasPlanActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox cmbFechasPlan;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JTextField txtDecoradas;
    private javax.swing.JTextField txtFecha;
    private javax.swing.JTextField txtRellenas;
    private javax.swing.JTextField txtSimples;
    // End of variables declaration//GEN-END:variables
}
